<script setup lang="ts">
import { ref, reactive, onMounted, watch } from "vue";
import { useRoute } from "vue-router";
import { router } from "@/router";

// 导入新的组件
import Dashboard from "./components/Dashboard.vue";
import Scenario from "./components/Scenario.vue";
import Task from "./components/Task.vue";
import VulnerabilityDetail from "./components/VulnerabilityDetail.vue";
import Template from "./components/Template.vue";
import MaliciousAddress from "./components/maliciousAddress.vue";
import Verification from "./components/Verification.vue";

const route = useRoute();
const activeTab = ref("0");

// 获取URL参数中的task
const taskParam = ref((route.query.task as string) || "");
</script>

<template>
  <div>
    <el-tabs v-model="activeTab" type="border-card">
      <!-- 仪表盘 -->
      <el-tab-pane label="仪表盘" value="0">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <Dashboard :task="taskParam" />
      </el-tab-pane>

      <!-- 威胁场景管理 -->
      <el-tab-pane label="威胁场景管理" value="1">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <Scenario :task="taskParam" />
      </el-tab-pane>

      <!-- 模板管理 -->
      <el-tab-pane label="模板管理" value="4">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <Template :task="taskParam" />
      </el-tab-pane>

      <!-- 任务管理 -->
      <el-tab-pane label="任务管理" value="2">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <Task :task="taskParam" />
      </el-tab-pane>

      <!-- 检测详情 -->
      <el-tab-pane label="检测详情" value="3">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <VulnerabilityDetail :task="taskParam" />
      </el-tab-pane>

      <!-- 恶意地址管理 -->
      <el-tab-pane label="恶意地址管理" value="5">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <MaliciousAddress :task="taskParam" />
      </el-tab-pane>

      <!-- 外联验证 -->
      <el-tab-pane label="外联验证" value="6">
        <div
          v-if="taskParam"
          style="display: flex; justify-content: space-between"
        >
          <div class="task-name">任务名称：{{ taskParam }}</div>
        </div>
        <Verification :task="taskParam" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<style lang="scss" scoped>
.search-form-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.el-btn-zese {
  background: #722ed1;
  color: white;
  border-color: #722ed1;
}

.el-btn-zese.is-disabled,
.el-btn-zese.is-disabled:focus,
.el-btn-zese.is-disabled:hover {
  background: #722ed1;
  color: white;
  border-color: #722ed1;
}
.task-name {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
  padding: 10px;
  border-radius: 5px;
}
</style>
